/**
 * 
 */
package com.kaixin001.tk.datatype;

/**
 * @author yuntxu
 *
 */
public class SeedItem implements Comparable {
	private String seedid = "";
	private int num = 0;
	private String name = "";
	private int price = 0;
	private int rank = 0;
	private int mhours = 0;
	private int fruit_minnum = 0;
	private int  fruit_maxnum = 0;
	private int fruit_minprice = 0;
	private int fruit_maxprice = 0;
	private int antistealdays = 0;
	private int yieldRate = -1;

	
	public String getSeedid() {
		return seedid;
	}
	public void setSeedid(String seedid) {
		this.seedid = seedid;
	}
	public int getNum() {
		return num;
	}
	public void setNum(int num) {
		this.num = num;
	}
	public void setNum(String num) {
		this.num = getNiceValue(num);
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getPrice() {
		return price;
	}
	public void setPrice(String price) {
		this.price = getNiceValue(price);
	}
	public int getRank() {
		return rank;
	}
	public void setRank(String rank) {
		this.rank = getNiceValue(rank);
	}
	public int getMhours() {
		return mhours;
	}
	public void setMhours(String mhours) {
		this.mhours = getNiceValue(mhours);
	}
	public int getFruit_minnum() {
		return fruit_minnum;
	}
	public void setFruit_minnum(String fruit_minnum) {
		this.fruit_minnum = getNiceValue(fruit_minnum);
	}
	public int getFruit_maxnum() {
		return fruit_maxnum;
	}
	public void setFruit_maxnum(String fruit_maxnum) {
		this.fruit_maxnum = getNiceValue(fruit_maxnum);
	}
	public int getFruit_minprice() {
		return fruit_minprice;
	}
	public void setFruit_minprice(String fruit_minprice) {
		this.fruit_minprice = getNiceValue(fruit_minprice);
	}
	public int getFruit_maxprice() {
		return fruit_maxprice;
	}
	public void setFruit_maxprice(String fruit_maxprice) {
		this.fruit_maxprice = getNiceValue(fruit_maxprice);
	}
	public int getAntistealdays() {
		return antistealdays;
	}
	public void setAntistealdays(String antistealdays) {
		
		this.antistealdays = getNiceValue(antistealdays);
	}
	
	public int computeYieldRate()
	{
		
		if(yieldRate<0)
		{
			int price = (fruit_minprice + fruit_maxprice) /2;
			int fruitNum = (fruit_maxnum + fruit_minnum) /2;
			
			if(mhours>0)
			{
				yieldRate = (price * fruitNum)/mhours;
			}
			else
			{
				yieldRate =  0;
			}
		}
		
		return yieldRate;
		
	}
	
	
	
	static int getNiceValue(String s)
	{
		int value=-1;
		try{
			if(s!=null)
			{
				value = Integer.parseInt(s);
			}
		}
		catch (Exception e) {			
		}
		return value;
	}
	
	public int compareTo(Object o) {
		SeedItem oo = (SeedItem) o;
		return oo.computeYieldRate() - this.computeYieldRate();
	}
	

}
